import request from '@/utils/request'
/**
 * 获取员工列表
 * @param {*} params
 * @returns
 */
export const getEmployeeList = (params) => {
  return request({
    url: '/sys/user',
    params
  })
}

/**
 * 导出员工的excel
 */

export const exportEmployee = () => {
  return request({
    url: '/sys/user/export',
    responseType: 'blob'
  })
}

/**
 * 下载员工导入模板
 */

export const getExportTemplate = () => {
  return request({
    url: '/sys/user/import/template',
    responseType: 'blob'
  })
}

/**
 * 上传用户的excel
 *
*/
export function uploadExcel(data) {
  return request({
    url: '/sys/user/import',
    method: 'post',
    data // form-data类型 因为要上传文件类型
  })
}

export const delEmployee = (id) => {
  return request({
    method: 'delete',
    url: `/sys/user/${id}`
  })
}/**
 * 新增员工
 * @param {} data
 * @returns
 */
export function addEmployee(data) {
  return request({
    url: '/sys/user',
    method: 'post',
    data
  })
}
/**
 *  获取员工详情
 * **/

export function getEmployeeDetail(id) {
  return request({
    url: `/sys/user/${id}`
  })
}
/**
 * 修改员工详情
 * @param {*} data
 * @returns
 */
export function updateEmployee(data) {
  return request({
    url: `/sys/user/${data.id}`,
    method: 'put',
    data
  })
}

/*
**角色权限列表
*/
export const getEnableRoleList = () => {
  return request({
    url: '/sys/role/list/enabled'
  })
}

/**
 * 分配员工角色
 * ***/

export function assignRole(data) {
  return request({
    url: '/sys/user/assignRoles',
    method: 'put',
    data
  })
}
